﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Enums.cs" company="">
//   
// </copyright>
// <summary>
//   The global variables.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.SqlClient;
using System.Globalization;

namespace Systemathics.FrameWork
{
    public sealed class GlobalVariables
    {
        public static string APPLICATION = Environment.GetEnvironmentVariable("SYSTEMATHICS", EnvironmentVariableTarget.User);
        public static string ASSEMBLY = APPLICATION +  "Assembly";
        public static string AUTOMATES = APPLICATION + "Automates";
        public static string RESOURCES = APPLICATION + "Resources";
        public static string PARAMETERS = APPLICATION +"Parameters";
        public static string REPORTS = APPLICATION + "Reports"; 
        public static string LOGS = APPLICATION + "Logs";
        public static string DB = Environment.GetEnvironmentVariable("SYSTEMATHICS_DB", EnvironmentVariableTarget.User);
        public static string SYSTEMATHICS_DATABASE_NAME = "Systemathics";
        public static string TICKCAPTURES_DATABASE_NAME = "TickCaptures";
        
        public static CultureInfo SystemathicsCulture()
        {
            var ci = new CultureInfo("en-US").Clone() as CultureInfo;
            ci.NumberFormat.CurrencySymbol = "€ ";
            return ci;
        }

        public static string SqlConnectionString(string dbName)
        {
            var sqlBuilder = new SqlConnectionStringBuilder
                                 {
                                     DataSource = ".\\SQLEXPRESS2008", 
                                     InitialCatalog = dbName, 
                                     IntegratedSecurity = true, 
                                     MultipleActiveResultSets = true,
                                     //AsynchronousProcessing = true
                                 };
            return sqlBuilder.ToString();
        }
        public static string EntitiesConnectionString()
        {
            var entityBuilder = new EntityConnectionStringBuilder
                                    {
                                        Provider = "System.Data.SqlClient", 
                                        ProviderConnectionString = SqlConnectionString(SYSTEMATHICS_DATABASE_NAME), 
                                        Metadata =
                                            @"res://Systemathics.FrameWork/Model.csdl|
                                            res://Systemathics.FrameWork/Model.ssdl|
                                            res://Systemathics.FrameWork/Model.msl"
                                    };

            return entityBuilder.ToString();
        }
    }

    public enum StrategyMode
    {
        /// <summary>
        /// The back test.
        /// </summary>
        BackTest, 

        /// <summary>
        /// The virtual.
        /// </summary>
        Virtual, 

        /// <summary>
        /// The live.
        /// </summary>
        Live
    }
    public enum Expo
    {
        /// <summary>
        /// The theo.
        /// </summary>
        Theo, 

        /// <summary>
        /// The working.
        /// </summary>
        Working, 

        /// <summary>
        /// The traded.
        /// </summary>
        Traded, 

        /// <summary>
        /// The inventory.
        /// </summary>
        Inventory
    }
    public enum DataSource
    {
        /// <summary>
        /// The current data provider.
        /// </summary>
        CurrentDataProvider, 

        /// <summary>
        /// The tick capture data base.
        /// </summary>
        TickCaptureDataBase
    }
    public enum ConnectionStatus
    {
        /// <summary>
        /// The connected.
        /// </summary>
        Connected, 

        /// <summary>
        /// The disconnected.
        /// </summary>
        Disconnected, 

        /// <summary>
        /// The unknown.
        /// </summary>
        Unknown
    }
    public enum BarData
    {
        /// <summary>
        /// The close.
        /// </summary>
        Close, 

        /// <summary>
        /// The high.
        /// </summary>
        High, 

        /// <summary>
        /// The low.
        /// </summary>
        Low, 

        /// <summary>
        /// The median.
        /// </summary>
        Median, 

        /// <summary>
        /// The open.
        /// </summary>
        Open, 

        /// <summary>
        /// The open int.
        /// </summary>
        OpenInt, 

        /// <summary>
        /// The typical.
        /// </summary>
        Typical, 

        /// <summary>
        /// The volume.
        /// </summary>
        Volume, 

        /// <summary>
        /// The weighted.
        /// </summary>
        Weighted
    }
    public enum BarType
    {
        /// <summary>
        /// The seconds.
        /// </summary>
        Seconds, 

        /// <summary>
        /// The ticks.
        /// </summary>
        Ticks, 

        /// <summary>
        /// The volume.
        /// </summary>
        Volume
    }
    public enum Cross
    {
        Above, 
        Below, 
        None
    }
    public enum Data
    {
        Quote, 
        Trade, 
        Bar
    }
    public enum Axis
    {
        Primary,
        Secondary
    }
    [Flags]
    [Serializable]
    public enum TickInfo
    {
        LastTrade = 0x01, 
        LastSize = 0x02, 
        BidSize_1 = 0x04, 
        Bid_1 = 0x08, 
        Ask_1 = 0x10, 
        AskSize_1 = 0x20, 
        BidSize_2 = 0x40, 
        Bid_2 = 0x80, 
        Ask_2 = 0x100, 
        AskSize_2 = 0x200, 
        BidSize_3 = 0x400, 
        Bid_3 = 0x800, 
        Ask_3 = 0x1000, 
        AskSize_3 = 0x2000, 
        BidSize_4 = 0x4000, 
        Bid_4 = 0x8000, 
        Ask_4 = 0x10000, 
        AskSize_4 = 0x20000, 
        BidSize_5 = 0x40000, 
        Bid_5 = 0x80000, 
        Ask_5 = 0x100000, 
        AskSize_5 = 0x200000, 
        Open = 0x400000, 
        Close = 0x800000, 
        NoTickInfo = 0x1000000
    }
    [Serializable]
    public enum QuoteLevel
    {
        /// <summary>
        /// The one.
        /// </summary>
        One = 0, 

        /// <summary>
        /// The two.
        /// </summary>
        Two = 1, 

        /// <summary>
        /// The three.
        /// </summary>
        Three = 2, 

        /// <summary>
        /// The four.
        /// </summary>
        Four = 3, 

        /// <summary>
        /// The five.
        /// </summary>
        Five = 4
    }
    public enum InstrumentType
    {
        Bond, 
        ETF, 
        Future, 
        Option, 
        Index, 
        Cash, 
        Unknown, 
    }
    public enum AssetClass
    {
        InterestRate, 
        Equity, 
        Commodity, 
        Forex,
        InterestRateIndex,
        EquityIndex,
        CommodityIndex,
        ForexIndex, 
        Mixed, 
        Unknown, 
    }
    public enum Sectors
    {
        Automobile, 
        Banks, 
        BasicResources, 
        Chemicals, 
        ConstructionsMaterials, 
        FinancialServices, 
        FoodBeverage, 
        HealthCare, 
        Industrial, 
        Insurance, 
        Media, 
        OilGaz,
        HouseHoldGoods, 
        Technology, 
        Telecommunications, 
        TravelLeisure, 
        Utilities, 
        RealEstates,
        Retail,
        Unknown, 
        Mixed
    }
    public enum CashManagementTrigger
    {
        /// <summary>
        /// The max bias triggered.
        /// </summary>
        MaxBiasTriggered, 

        /// <summary>
        /// The max leverage triggered.
        /// </summary>
        MarginRequirementTriggered, 

        /// <summary>
        /// The max draw down triggered.
        /// </summary>
        MaxDrawDownTriggered, 

        /// <summary>
        /// The cash equity negative.
        /// </summary>
        CashEquityNegative
    }
    [Serializable]
    public enum OrderStyle
    {
        /// <summary>
        /// A Market order is an order to buy or sell an asset at the bid or offer price currently available in the marketplace.
        /// Bonds, Forex, Futures, Future Options, Options, Stocks, Warrants
        /// </summary>
        [Description("MKT")]
        Market,
        /// <summary>
        /// A market order that is submitted to execute as close to the closing price as possible.
        /// Non US Futures, Non US Options, Stocks
        /// </summary>
        [Description("MOC")]
        MarketOnClose,
        /// <summary>
        /// A limit order is an order to buy or sell a contract at a specified price or better.
        /// Bonds, Forex, Futures, Future Options, Options, Stocks, Warrants
        /// </summary>
        [Description("LMT")]
        Limit,
        /// <summary>
        /// An LOC (Limit-on-Close) order that executes at the closing price if the closing price is at or better than the submitted limit price, according to the rules of the specific exchange. Otherwise the order will be cancelled. 
        /// Non US Futures , Stocks
        /// </summary>
        [Description("LMTCLS")]
        LimitOnClose,
        /// <summary>
        /// A Stop order becomes a market order to buy or sell securities or commodities once the specified stop price is attained or penetrated.
        /// Forex, Futures, Future Options, Options, Stocks, Warrants
        /// </summary>
        [Description("STP")]
        Stop,
        /// <summary>
        /// A STOP-LIMIT order is similar to a stop order in that a stop price will activate the order. However, once activated, the stop-limit order becomes a buy limit or sell limit order and can only be executed at a specific price or better. It is a combination of both the stop order and the limit order.
        /// Forex, Futures, Options, Stocks
        /// </summary>
        [Description("STP LMT")]
        StopLimit,
        /// <summary>
        /// A trailing stop for a sell order sets the stop price at a fixed amount below the market price. If the market price rises, the stop loss price rises by the increased amount, but if the stock price falls, the stop loss price remains the same. The reverse is true for a buy trailing stop order.
        /// Forex, Futures, Future Options, Options, Stocks, Warrants
        /// </summary>
        [Description("TRAIL")]
        TrailingStop,
        /// <summary>
        /// A trailing stop limit for a sell order sets the stop price at a fixed amount below the market price and defines a limit price for the sell order. If the market price rises, the stop loss price rises by the increased amount, but if the stock price falls, the stop loss price remains the same. When the order triggers, a limit order is submitted at the price you defined. The reverse is true for a buy trailing stop limit order.
        /// Forex, Futures, Future Options, Options, Stocks, Warrants
        /// </summary>
        [Description("TRAILLIMIT")]
        TrailingStopLimit,
        /// <summary>
        /// A Relative order derives its price from a combination of the market quote and a user-defined offset amount. The order is submitted as a limit order and modified according to the pricing logic until it is executed or you cancel the order.
        /// Options, Stocks
        /// </summary>
        [Description("REL")]
        Relative,
        /// <summary>
        /// The VWAP for a stock is calculated by adding the dollars traded for every transaction in that stock ("price" x "number of shares traded") and dividing the total shares traded. By default, a VWAP order is computed from the open of the market to the market close, and is calculated by volume weighting all transactions during this time period. TWS allows you to modify the cut-off and expiration times using the Time in Force and Expiration Date fields, respectively.
        /// Stocks
        /// </summary>
        //[Description("VWAP")]
        //VWAP,
        ///// <summary>
        ///// TWS Version 857 introduced volatility trading of options, and a new order type, "VOL." What happens with VOL orders is that the limit price that is sent to the exchange is computed by TWS as a function of a daily or annualized option volatility provided by the user. VOL orders can be placed for any US option that trades on the BOX exchange. VOL orders are eligible for dynamic management, a powerful new functionality wherein TWS can manage options orders in response to specifications set by the user.
        ///// </summary>
        //[Description("VOL")]
        //Volatility,
        ///// <summary>
        ///// Default - used for Delta Neutral Order Type
        ///// </summary>
        //[Description("Default")]
        //Default,
        /// <summary>
        /// Scale Order.
        /// </summary>
        //[Description("SCALE")]
        //Scale
        /// <summary>
        /// An order that is pegged to buy on the best offer and sell on the best bid.
        /// Your order is pegged to buy on the best offer and sell on the best bid. You can also use an offset amount which is subtracted from the best offer for a buy order, and added to the best bid for a sell order.
        /// Stocks
        /// </summary>
        //[Description("PEGMKT")]
        //PeggedToMarket,
    }
    [Serializable]
    public enum TimeInForce
    {
        /// <summary>
        /// A Day order is canceled if it does not execute by the close of the trading day. Unless otherwise specified, every order is a Day order.
        /// </summary>
        [Description("DAY")]
        Day,
        /// <summary>
        /// Good Until Cancel : remains active in the market until you decide to cancel it
        /// </summary>
        [Description("GTC")]
        GoodTillCancel,
        /// <summary>
        /// Immediate Or Cancel: Immediate-Or-Cancel (IOC) order is an order that must be filled immediately at the limit price or better only. If the order cannot be filled immediately or fully (i.e. only partially filled), the unfilled portion will be cancelled.
        /// You can set the time in force for MARKET or LIMIT orders as IOC. This dictates that any portion of the order not executed immediately after it becomes available on the market will be cancelled.
        /// </summary>
        [Description("IOC")]
        ImmediateOrCancel,
        /// <summary>
        /// Setting FOK as the time in force dictates that the ENTIRE order must execute immediately or be canceled.
        /// </summary>
        [Description("FOK")]
        FillOrKill,
        /// <summary>
        /// A Good-Til-Date order will remain working within the system and in the marketplace until it executes or until the close of the market on the date specified
        /// </summary>
        [Description("GTD")]
        GoodTillDate,
        /// <summary>
        /// Market On Open
        /// </summary>
        [Description("OPG")]
        MarketOnOpen,
        /// <summary>
        /// Undefined
        /// </summary>
        [Description("")]
        Undefined
    }
    [Flags]
    [Serializable]
    public enum OrderStatus
    {
        /// <summary>
        /// The ack.
        /// </summary>
        ACK = 0x01, 

        /// <summary>
        /// The reject.
        /// </summary>
        REJECT = 0x02, 

        /// <summary>
        /// The ac k_ cancel.
        /// </summary>
        ACK_CANCEL = 0x04, 

        /// <summary>
        /// The rejec t_ cancel.
        /// </summary>
        REJECT_CANCEL = 0x08, 

        /// <summary>
        /// The ac k_ modify.
        /// </summary>
        ACK_MODIFY = 0x10, 

        /// <summary>
        /// The rejec t_ modify.
        /// </summary>
        REJECT_MODIFY = 0x20, 

        /// <summary>
        /// The filled.
        /// </summary>
        FILLED = 0x40, 

        /// <summary>
        /// The partiall y_ filled.
        /// </summary>
        PARTIALLY_FILLED = 0x80, 

        ///// <summary>
        ///// The ou t_ report.
        ///// </summary>
        //OUT_REPORT = 0x100, 

        ///// <summary>
        ///// The correctio n_ report.
        ///// </summary>
        //CORRECTION_REPORT = 0x200
    }
    public enum SytemathicsSounds
    {
        /// <summary>
        /// The ack.
        /// </summary>
        ACK, 

        /// <summary>
        /// The reject.
        /// </summary>
        REJECT, 

        /// <summary>
        /// The ac k_ cancel.
        /// </summary>
        ACK_CANCEL, 

        /// <summary>
        /// The rejec t_ cancel.
        /// </summary>
        REJECT_CANCEL, 

        /// <summary>
        /// The ac k_ modify.
        /// </summary>
        ACK_MODIFY, 

        /// <summary>
        /// The rejec t_ modify.
        /// </summary>
        REJECT_MODIFY, 

        /// <summary>
        /// The filled.
        /// </summary>
        FILLED, 

        /// <summary>
        /// The partiall y_ filled.
        /// </summary>
        PARTIALLY_FILLED, 

        /// <summary>
        /// The ou t_ report.
        /// </summary>
        OUT_REPORT, 

        /// <summary>
        /// The correctio n_ report.
        /// </summary>
        CORRECTION_REPORT, 

        /// <summary>
        /// The connected.
        /// </summary>
        CONNECTED, 

        /// <summary>
        /// The disconnected.
        /// </summary>
        DISCONNECTED
    }
    public enum OrderSide
    {
        /// <summary>
        /// The buy.
        /// </summary>
        Buy = 1, 

        /// <summary>
        /// The sell.
        /// </summary>
        Sell = -1
    }

    public enum Countries
    {
        FRANCE,
        GERMANY,
        ITALY,
        BELGIUM,
        NETHERLANDS,
        SPAIN,
        SWEDEN,
        SWITZERLAND,
        UK,
        USA,
        CANADA,
        MEXICO,
        AUSTRALIA,
        HONGKONG,
        SINGAPOUR,
        JAPAN,
        INDIA,
        KOREA,
        WORLDWIDE
    }
}